
//
//  NewShouYiViewController.m
//  wangzhe
//
//  Created by 李 佳伟 on 2018/3/13.
//  Copyright © 2018年 李 佳伟. All rights reserved.
//

#import "NewShouYiViewController.h"
#import "JTCSM.h"
#import "LCPieView.h"
#import "MyInfoView.h"
#import "MyDoubleLabelView.h"
#import "NewShouYiMXZhuViewController.h"
#import "NewPaiHangViewController.h"
#import "NewJiaoYiInfoViewController.h"

static CGFloat top = 31;

@interface NewShouYiViewController ()
{
    CGFloat lcpicSize ;
    CGFloat myinfoHeight ;
}
@property (nonatomic,strong)  LCPieView *lcPieV;
@property (nonatomic,strong) MyDoubleLabelView *bottomleftView;
@property (nonatomic,strong) MyDoubleLabelView *bottomrightView;
@property (nonatomic,strong) MyDoubleLabelView *headerDoubleView;
@end

@implementation NewShouYiViewController

- (void)gotBack{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = NO;

}
- (void)viewDidLoad {
    [super viewDidLoad];
    [df isRemoveTarbar:YES];
    self.navigationController.navigationBar.hidden = NO;
    self.view.backgroundColor =[UIColor whiteColor];
    leftBarButtonItems_rightBarButtonItems *leftbtn = KCUSTOMNAVIGSTION_ALLOC;
    self.navigationItem.leftBarButtonItem = [leftbtn setBarButtonItemsImageName:@"fanhui.png" frame:KLeftBarButtonItemFrame_image target:self SEL:@selector(gotBack)];
    
    lcpicSize =200*[JTCSMSingle shareSingle].adaptationNumber;
    myinfoHeight = 50*[JTCSMSingle shareSingle].adaptationNumber;
    _lcPieV = [[LCPieView alloc]initWithFrame:CGRectMake((KCONTROLLERWith-lcpicSize)/2, top, lcpicSize, lcpicSize)];
    [self.view addSubview:_lcPieV];
    LCPieViewModel *modelP0 = [LCPieViewModel modelWithValue:arc4random_uniform(100) color:[df colorWithHexString:@"fe970f" alpha:1] text:@""];
    LCPieViewModel *modelP1 = [LCPieViewModel modelWithValue:arc4random_uniform(100) color:[df colorWithHexString:@"1795cd" alpha:1] text:@""];
    LCPieViewModel *modelP2 = [LCPieViewModel modelWithValue:arc4random_uniform(100) color:[df colorWithHexString:@"0fcccd" alpha:1] text:@""];
    [_lcPieV showPieViewWithDataSource:@[modelP0, modelP1, modelP2]];
    
    UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake((KCONTROLLERWith-lcpicSize)/2, top, lcpicSize, lcpicSize)];
    headerView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:headerView];
    headerView.userInteractionEnabled = YES;
    
    _headerDoubleView = [[MyDoubleLabelView alloc]initWithFrame:CGRectMake(0, 0, lcpicSize, lcpicSize) titleFontsize:18 titlecolor:[df colorWithHexString:@"333333" alpha:1] contentFontsize:12 contentcolor:[df colorWithHexString:@"333333" alpha:1]];
    [headerView addSubview:_headerDoubleView];
    _headerDoubleView.userInteractionEnabled = YES;
    [_headerDoubleView InsertSpacesetvalueWithModel:@{KDoubleLabelTitle:@"183450.00",KDoubleLabelContent:@"昨日收益（元）"} changeLabelY:16];
    [df addTapGestureRecognizerWithTarget:self action:@selector(gotoNextVC) andaddView:_headerDoubleView];
    CGFloat tapImageHeight = 50;
    CGFloat tapImageWidth = tapImageHeight*1.7143;
    UIImageView *tapImageV = [[UIImageView alloc]initWithFrame:CGRectMake(KCONTROLLERWith-tapImageWidth, top, tapImageWidth, tapImageHeight)];
    tapImageV.userInteractionEnabled = YES;
    tapImageV.image = [UIImage imageNamed:@"查看排行榜.png"];
    [self.view addSubview:tapImageV];
    [df addTapGestureRecognizerWithTarget:self action:@selector(gotoNewPaiHangViewController) andaddView:tapImageV];
    
    
    [self layoutSubeviews];
    // Do any additional setup after loading the view.
}
- (void)gotoNewPaiHangViewController{
    NewPaiHangViewController *vc = [[NewPaiHangViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark 跳转下一个VC
- (void)gotoNextVC{
    NewShouYiMXZhuViewController *vc = [[NewShouYiMXZhuViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)layoutSubeviews{
    CGFloat mydoubleViewHiehgt = 50;
    self.bottomleftView = [[MyDoubleLabelView alloc]initWithFrame:CGRectMake(0, top*2+lcpicSize, KCONTROLLERWith/2, mydoubleViewHiehgt) titleFontsize:17 titlecolor:RGBACOLOR(51, 51, 51, 1) contentFontsize:12 contentcolor:[df colorWithHexString:@"666666" alpha:1]];
    [self.view addSubview:self.bottomleftView];
    [self.bottomleftView InsertSpacesetvalueWithModel:@{KDoubleLabelTitle:@"183450.00",KDoubleLabelContent:@"32884387笔"} changeLabelY:16];
    
    self.bottomrightView = [[MyDoubleLabelView alloc]initWithFrame:CGRectMake(KCONTROLLERWith/2, top*2+lcpicSize, KCONTROLLERWith/2, mydoubleViewHiehgt) titleFontsize:17 titlecolor:RGBACOLOR(51, 51, 51, 1) contentFontsize:12 contentcolor:[df colorWithHexString:@"666666" alpha:1]];
    [self.view addSubview:self.bottomrightView];
    [self.bottomrightView InsertSpacesetvalueWithModel:@{KDoubleLabelTitle:@"183450.00",KDoubleLabelContent:@"32884387笔"} changeLabelY:16];
    
    [df newlineViewWithHeightofTop:KVIEW_Y(_bottomleftView)+top superView:self.view spacing:0 color:RGBACOLOR(241, 241, 241, 1) lineHeight:10];
    
    NSArray *array = @[@"交易收益（元）",@"拓客收益（元）",@"互动奖励（元）"];
    NSArray *iamgearray = @[@"newjiaoyi.png",@"newtuoke.png",@"newhudong.png"];
    MyInfoView *view1;
    for (int i = 0; i < array.count; i++) {
        view1 = [[MyInfoView alloc]initWithFrame:CGRectMake(0, KVIEW_Y(self.bottomleftView)+top+myinfoHeight*i, KCONTROLLERWith, myinfoHeight) imagename:iamgearray[i] title:array[i]placeholder:nil isShowLabel:ImageandlabelViewType radioBtnIndex:0 GroupId:@""];
        view1.tag = 100+i;
        view1.userInteractionEnabled = YES;
        view1.footerLabel.text = @"+700.00";
        [df addTapGestureRecognizerWithTarget:self action:@selector(gotoVC:) andaddView:view1];
        [self.view addSubview:view1];
        [view1 showdianview:YES];
    }
    
    UIButton *tijiaobutton = [UIButton buttonWithType:UIButtonTypeCustom];
    tijiaobutton.frame = CGRectMake(25, KVIEW_Y(view1)+70*[JTCSMSingle shareSingle].adaptationNumber, KCONTROLLERWith-40, 50);
    [tijiaobutton addTarget:self action:@selector(tijiao) forControlEvents:UIControlEventTouchUpInside];
    [df layerWithView:tijiaobutton radius:25 width:0 color:nil];
    tijiaobutton.backgroundColor = KZhuTiRGB;
    [tijiaobutton setTitleColor:RGBACOLOR(51, 51, 51, 1) forState:UIControlStateNormal];
    [tijiaobutton setTitle:@"转入红包" forState:UIControlStateNormal];
    [self.view addSubview:tijiaobutton];
}
- (void)gotoVC:(UITapGestureRecognizer *)tap{
    NSInteger tagnumber = [tap view].tag-100;
    switch (tagnumber) {
        case 0:
            [self gotoAboutVCWithType:JiaoYiType titleName:@"交易收益"];
            break;
        case 1:
            [self gotoAboutVCWithType:TuoKeType titleName:@"拓客收益"];
            break;
        case 2:
            [self gotoAboutVCWithType:HuDongType titleName:@"互动收益"];
            break;
            
        default:
            break;
    }
    
}
- (void)gotoAboutVCWithType:(ShouYiType)type titleName:(NSString *)name{
    NewJiaoYiInfoViewController *vc = [[NewJiaoYiInfoViewController alloc]init];
    vc.nameTitle = name;
    vc.mytype = type;
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)tijiao{
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
